# -*- coding: utf-8 -*-

import Core as _core

Ref = _core.Ref
Include = _core.Include
Pragma = _core.Pragma

Int8 = _core.Int8
UInt8 = _core.UInt8
Int16 = _core.Int16
UInt16 = _core.UInt16
Int32 = _core.Int32
UInt32 = _core.UInt32
Int64 = _core.Int64
UInt64 = _core.UInt64
Single = _core.Single
Double = _core.Double
IntPtr = _core.IntPtr
UIntPtr = _core.UIntPtr
String = _core.String
WString = _core.WString
Void = _core.Void
Boolean = _core.Boolean

Public = _core.Public
Protected = _core.Protected
Private = _core.Private

In = _core.In
Out = _core.Out
InOut = _core.InOut


class Module(_core.OwnerBase):
    def __init__(self, id=None, *elements, **kwargs):
        e = _core.get_ast_node(elements)
        _core.OwnerBase.__init__(self, _core.Module(id, *e, **kwargs), *e)


class Interface(_core.OwnerBase):
    def __init__(self, id, *elements, **kwargs):
        e = _core.get_ast_node(elements)
        _core.OwnerBase.__init__(self, _core.Interface(id, *e, **kwargs), *e)


class Struct(_core.OwnerBase):
    def __init__(self, id, *elements, **kwargs):
        e = _core.get_ast_node(elements)
        _core.OwnerBase.__init__(self, _core.Struct(id, *e, **kwargs), *e)


class Typedef(_core.Base):
    def __init__(self, id, type, **kwargs):
        _core.Base.__init__(self, _core.Typedef(id, _core.get_ast_node(type), **kwargs))


class Enum(_core.Base):
    def __init__(self, id, type=Void, **kwargs):
        _core.Base.__init__(self, _core.Enum(id, _core.get_ast_node(type), **kwargs))


class Operation(_core.Base):
    def __init__(self, id, ret, *params, **kwargs):
        _core.Base.__init__(self, _core.Operation(id, _core.get_ast_node(ret), *_core.get_ast_node(params), **kwargs))


class Param(_core.Base):
    def __init__(self, id, type, **kwargs):
        _core.Base.__init__(self, _core.Param(id, _core.get_ast_node(type), **kwargs))


class Attribute(_core.Base):
    def __init__(self, id, type, default_access=Private, **kwargs):
        _core.Base.__init__(self, _core.Attribute(id, _core.get_ast_node(type), default_access, **kwargs))


class Const(_core.Base):
    def __init__(self, id, type, value, **kwargs):
        _core.Base.__init__(self, _core.Const(id, _core.get_ast_node(type), value, **kwargs))

    def __add__(self, rh):
        return _core.get_ast_node(type).value + rh
    def __sub__(self, rh):
        return _core.get_ast_node(type).value - rh
    def __mul__(self, rh):
        return _core.get_ast_node(type).value * rh
    def __radd__(self, lh):
        return lh + _core.get_ast_node(type).value
    def __rsub__(self, lh):
        return lh - _core.get_ast_node(type).value
    def __rmul__(self, lh):
        return lh * _core.get_ast_node(type).value


def Typedefs(**kwargs):
    typedefs = []
    for k in kwargs:
        typedefs.append(Typedef(k, kwargs[k]))
    return typedefs


def Attributes(**kwargs):
    attributes = []
    for k in kwargs:
        attributes.append(Attribute(k, kwargs[k]))
    return attributes


def Consts(type, **kwargs):
    consts = []
    for k in kwargs:
        consts.append(Const(k, type, kwargs[k]))
    return consts
